$(function () {
    $("#complete_datagrid").datagrid({
        fitColumns: true,
        fit: true,
        toolbar: '#complete_toolbar',
        url: '/guard/completeList.do',
        pagination: true,
        striped: true,
        rownumbers: true,
        singleSelect: true,
        columns: [[
            {title: '保单编号', field: 'num',align:'center', width: '100'},
            {title: '投保人', field: 'client' ,align:'center', width: '100', formatter: function (value, row, index) {
                    return row? row.client.name:"";
                }},
            {title: '申请日期', field: 'appDate' ,align:'center', width: '100'},
            {title: '核保日期', field: 'auditDate' ,align:'center', width: '100'},
            {title: '保险截止日', field: 'overtime' ,align:'center', width: '100'},
            {
                title: '保险时长', field: 'product.years' ,align:'center', width: '100', formatter: function (value, row, index) {
                    return row ? row.product.years : "";
                }
            },
            {title: '业务员', field: 'employeeName' ,align:'center', width: '100'},
            {title: '审核人', field: 'auditName' ,align:'center', width: '100'},
            {title: '投保总金额', field: 'product.cost' ,align:'center', width: '100', formatter: function (value, row, index){
                    return row ? row.product.cost : "";
                }},
            {
                title: '状态', field: 'state' ,align:'center', width: '100', formatter: function (value, row, index) {
                    return  "<font color='red'>已缴费</font>"
                }
            }
        ]]

    })

    $("#complete_dialog").dialog({
        width: 350,
        height: 470,
        buttons: '#complete_buttons',
        closed: true,
        onClose: function () {
            $("#complete_form").form("clear")
        }
    })
    var methodObj = {

        query: function () {
            var clientName = $("#clientName").textbox("getValue");
            var employeeName = $("#employeeName").textbox("getValue");
            var num = $("#num").textbox("getValue");

            $("#checked_datagrid").datagrid('load', {
                clientName: clientName,
                num: num,
                employeeName:employeeName
            });
        }

    }


    $("a[data-cmd]").click(function () {
        var cmd = $(this).data("cmd");
        methodObj[cmd](this);
    })

})

